﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BRS.BidModule
{
    public partial class AddProject : Form
    {
        Entities brs = new Entities(); 
        Users us=new Users();
        public AddProject(Users user)
        {
          
            InitializeComponent();
            us = user;
            this.textBox4.Text = us.UserName;
            this.dateTimePicker1.Value = DateTime.Parse("09:30:00");
            comboBox1.DisplayMember = "Name";//控件显示的列名  
            comboBox1.ValueMember = "Name";//控件值的列名  

            comboBox1.DataSource = brs.TenderMsg.Where(p => p.Type=="招标人").OrderBy(p=>p.AddTime).ToList();

            comboBox2.DisplayMember = "Name";//控件显示的列名  
            comboBox2.ValueMember = "Name";//控件值的列名  
            comboBox2.DataSource = brs.TenderMsg.Where(p => p.Type == "招标代理").OrderBy(p => p.AddTime).ToList();
        }
        public AddProject()
        {
            InitializeComponent();
            
             //this.Text = "nihao";
           
        }
      
        private void button1_Click(object sender, EventArgs e)
        {
            tb_Project pro = new tb_Project()
            {
                
                ProjectName = this.textBox1.Text,
                ProjectCode = this.textBox2.Text,               
                CreateDate = DateTime.Now,       
                Leader =us.UserName,// 创建项目使用用户码来创建，此地可以根据需要修改，要求用号码应该唯一
                IsDone = this.checkBox1.Checked,
                Enabled = this.checkBox2.Checked,
                Deadline=dateTimePicker1.Value,
                Deaddate=dateTimePicker1.Value.Date.AddDays(1),
                Note = this.textBox3.Text,
                Tender = this.comboBox1.SelectedValue.ToString(),
                TenderAgent = this.comboBox2.SelectedValue.ToString(),
                FilePath =""



            };
            //if (label10.Text == "")
            brs.tb_Project.Add(pro);
            //else brs.tb_Project.s.Add(pro);
            var ups = brs.SaveChanges();
            if (ups > 0)
            {
                MessageBox.Show("新增项目成功！");
                
            }else MessageBox.Show("新增失败！");

        }
    }
}
